package org.jianfa.mq.seckill.config;

import com.github.pagehelper.PageHelper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 参考 MybatisAutoConfiguration
 */
@Configuration
@MapperScan(basePackages = {"org.jianfa.mq.seckill.mapper"})
public class DatasourceConfig {

    @Bean
    public PageHelper pageInterceptor(){
        PageHelper pageInterceptor = new PageHelper();
        // 详见 com.github.pagehelper.page.PageParams
        Properties p = new Properties();
//        p.setProperty("offsetAsPageNum", "false");
//        p.setProperty("rowBoundsWithCount", "false");
//        p.setProperty("reasonable", "false");
        // 设置数据库方言 ， 也可以不设置，会动态获取
        p.setProperty("dialect", "mysql");
        pageInterceptor.setProperties(p);
        return pageInterceptor;
    }
}
